
package robotinterface;

/**
 *  Nate Hemmes
 *  Last Updated: 10/22/2012
 */


import java.awt.Dimension;
import javax.swing.*;
import robotinterface.client.RobotClient;


public class RobotInterface extends JPanel
{

    int width = 0;
    int height = 0;
    
    JPanel savedPositionsPanel;
    JComponent orientationTab;
    JComponent manualTab;
    

    RobotClient robotClient = new RobotClient();

    public RobotInterface(int w, int h)
    {
                
        width = w;
        height = h;

        SpringLayout layout = new SpringLayout();
        setLayout(layout);
        setPreferredSize(new Dimension(width, height));

        savedPositionsPanel = new SavePanel();

        JTabbedPane tabbedPane = new JTabbedPane();

        manualTab = new ManualTab();
        orientationTab = new OrientationTab();
        manualTab.setToolTipText( "Control pose of robotic arm." );
        orientationTab.setToolTipText( "Control robotic arm position" );

        tabbedPane.addTab("Manual", manualTab);
        tabbedPane.addTab("Orientation", orientationTab);

        add(savedPositionsPanel);
        add(tabbedPane);
        layout.putConstraint(SpringLayout.WEST, savedPositionsPanel, 10, SpringLayout.WEST, this);
        layout.putConstraint(SpringLayout.NORTH, savedPositionsPanel, 31, SpringLayout.NORTH, this);
        layout.putConstraint(SpringLayout.SOUTH, savedPositionsPanel, -9, SpringLayout.SOUTH, this);
        layout.putConstraint(SpringLayout.EAST, savedPositionsPanel, 220, SpringLayout.WEST, this);
        layout.putConstraint(SpringLayout.WEST, tabbedPane, 10, SpringLayout.EAST, savedPositionsPanel);
        layout.putConstraint(SpringLayout.NORTH, tabbedPane, 10, SpringLayout.NORTH, this);
        layout.putConstraint(SpringLayout.EAST, tabbedPane, -10, SpringLayout.EAST, this);
        layout.putConstraint(SpringLayout.SOUTH, tabbedPane, -10, SpringLayout.SOUTH, this);
    }

    public void resetVar(int w, int h){
        width = w;
        height = h;
    }

    private static void createAndShowGUI() {
        int w = 750;
        int h = 625;
        final JFrame frame = new JFrame("Robot Interface");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setResizable(false);
        frame.setPreferredSize(new Dimension(w, h));

        final RobotInterface contentPane = new RobotInterface(w, h);
        contentPane.setOpaque(true);

        MenuBar menu = new MenuBar();
        frame.setJMenuBar(menu.createMenuBar());

        frame.setContentPane(contentPane);
        contentPane.resetVar(frame.getContentPane().getWidth(), frame.getContentPane().getHeight());

        frame.pack();
        frame.setVisible(true);

    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                createAndShowGUI();
            }
        });
    }
}